<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('【请填写功能名称】列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>产品名称：</label>
                                <input type="text" name="product_name"/>
                            </li>
                            <li>
                                <label>所属单位：</label>
                                <input type="text" name="departname"/>
                            </li>
                            <li>
                                <label>订阅编号：</label>
                                <input type="text" name="work_code"/>
                            </li>
                            <li>
                                <label>状态：</label>
                                <!--<input type="text" name="status"/>-->
                                <select id="status"  name="status">
                                    <option value="1">进行中</option>
                                    <option value="0">未开始</option>
                                    <option value="2">已结束</option>
                                </select>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
              <!--  <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:order:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:order:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:order:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:order:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:order:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:order:remove')}]];
        var prefix = ctx + "system/order";

        $(function() {
            var options = {
                url: prefix + "/listdy",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/removedy",
                exportUrl: prefix + "/export",
                modalName: "【请填写功能名称】",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '${comment}',
                    visible: false
                },
                    {
                        field: 'work_code',
                        title: '订阅编号'
                    },
                    {
                        field: 'create_date',
                        title: '订阅时间'
                    },
                    {
                        field: 'begin_date',
                        title: '任务开始时间'
                    },
                    {
                        field: 'end_date',
                        title: '任务完成时间'
                    },
                    {
                        field: 'real_name',
                        title: '订阅人',
                    },
                    /*{
                        field: 'userId',
                        title: '订阅人'
                    },*/
                    /*{
                        field: 'departname',
                        title: '所属单位'
                    },*/
                    {
                        field: 'product_name',
                        title: '产品',
                        formatter: function(value, item, index) {
                            if (value == null) {
                                return item.product_id+"(智能网格)";
                            }else{
                                return value;
                            }
                        }
                    },
                    {
                        field: 'work_type',
                        title: '订阅类型',

                        formatter: function(value, item, index) {
                            //console.log(item.work_type)
                            if (item.work_type == '0') {
                                return '<span class="label label-primary">全覆盖</span>';
                            }
                            else{
                                return '<span class="label label-warning"><button style="background-color: #f8ac59;border: 0px" onclick="fanwei('+item.minLon+','+item.maxLon+','+item.minLat+','+item.maxLat+')">部分覆盖</button></span><br><span class="label label-warning">范围:(minLon:'+item.minLon+',maxLon:'+item.maxLon+',minLat:'+item.minLat+',maxLat:'+item.maxLat+')</span>';
                            }
                        }
                    },
                    {
                        field: 'status',
                        title: '状态',
                        formatter: function(value, item, index) {
                            //console.log(item.status)
                            if (item.status == '0') {
                                return '<span class="label label-primary">未开始</span>';
                            }
                            else if (item.status == '1') {
                                return '<span class="label label-success">进行中</span>';
                            }
                            else if(item.status == '2'){
                                return '<span class="label label-warning">已结束</span>';
                            }
                        }
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
/*                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');*/
                        actions.push('<a class="btn btn-warning btn-xs " href="javascript:void(0)" onclick="xzd('+row.work_code+')">下载单</a> ');
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="renewalProduct(\''+row.id+'\',\''+row.work_type+'\')">一键续订</a> ');
                        actions.push('&nbsp;<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')">删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

       function xzd(ddid){
           console.log("点击下载单"+ddid)
           $.modal.open("下载单预览","/system/order/xz/"+ddid);
        }
        function renewalProduct(id,work_type){
            $.operate.post(prefix+"/renewalProduct",{id:id,work_type:work_type})
        }
        function fanwei(minLon,maxLon,minLat,maxLat){
            $.modal.open("范围","/leaflet/map/fw/"+minLon+'/'+maxLon+'/'+minLat+'/'+maxLat,600,500);
        }
    </script>
</body>
</html>